import 'package:get_it/get_it.dart';
import 'package:mobile_app.core/injection_container.dart' as core_di;
import 'package:mobile_app.home.menu.settings/pronunciation_settings_page/domain/helpers/denormalize_speech_rate/helper.dart';
import 'package:mobile_app.home.menu.settings/pronunciation_settings_page/domain/helpers/get_max_speech_rate/helper.dart';
import 'package:mobile_app.home.menu.settings/pronunciation_settings_page/domain/helpers/get_min_speech_rate/helper.dart';
import 'package:mobile_app.home.menu.settings/pronunciation_settings_page/domain/helpers/get_pronunciation_demonstration_sentence/helper.dart';
import 'package:mobile_app.home.menu.settings/pronunciation_settings_page/domain/helpers/normalize_speech_rate/helper.dart';
import 'package:mobile_app.home.menu.settings/pronunciation_settings_page/domain/helpers/update_pronunciation_settings_from_voice/helper.dart';
import 'package:mobile_app.home.menu.settings/pronunciation_settings_page/domain/use_cases/change_dialect/use_case.dart';
import 'package:mobile_app.home.menu.settings/pronunciation_settings_page/domain/use_cases/change_speech_rate/use_case.dart';
import 'package:mobile_app.home.menu.settings/pronunciation_settings_page/domain/use_cases/change_voice/use_case.dart';
import 'package:mobile_app.home.menu.settings/pronunciation_settings_page/domain/use_cases/handle_pronunciation_settings_outer_update/use_case.dart';
import 'package:mobile_app.home.menu.settings/pronunciation_settings_page/domain/use_cases/initialize/use_case.dart';

final sl = GetIt.asNewInstance();

Future<void> init() async {
  // domain helpers

  sl.registerLazySingleton<DenormalizeSpeechRate>(() {
    return DenormalizeSpeechRateImpl(
      getMaxSpeechRate: sl(),
      getMinSpeechRate: sl(),
    );
  });

  sl.registerLazySingleton<GetMaxSpeechRate>(() {
    return const GetMaxSpeechRateImpl();
  });

  sl.registerLazySingleton<GetMinSpeechRate>(() {
    return const GetMinSpeechRateImpl();
  });

  sl.registerLazySingleton<GetPronunciationDemonstrationSentence>(() {
    return const GetPronunciationDemonstrationSentenceImpl();
  });

  sl.registerLazySingleton<NormalizeSpeechRate>(() {
    return NormalizeSpeechRateImpl(
      getMaxSpeechRate: sl(),
      getMinSpeechRate: sl(),
    );
  });

  sl.registerLazySingleton<UpdatePronunciationSettingsFromVoice>(() {
    return const UpdatePronunciationSettingsFromVoiceImpl();
  });

  // use cases

  sl.registerLazySingleton<ChangeDialect>(() {
    return ChangeDialectImpl(
      createPronunciationSettingsDataFromPronunciationSettings: core_di.sl(),
      createPronunciationSettingsFromPronunciationSettingsData: core_di.sl(),
      getTtsVoice: core_di.sl(),
      getPronunciationDemonstrationSentence: sl(),
      makePronunciationSettingsDataConsistent: core_di.sl(),
      ttsService: core_di.sl(),
      settingsRepository: core_di.sl(),
    );
  });

  sl.registerLazySingleton<ChangeSpeechRate>(() {
    return ChangeSpeechRateImpl(
      createPronunciationSettingsDataFromPronunciationSettings: core_di.sl(),
      getPronunciationDemonstrationSentence: sl(),
      denormalizeSpeechRate: sl(),
      ttsService: core_di.sl(),
      settingsRepository: core_di.sl(),
    );
  });

  sl.registerLazySingleton<ChangeVoice>(() {
    return ChangeVoiceImpl(
      createPronunciationSettingsDataFromPronunciationSettings: core_di.sl(),
      getTtsVoice: core_di.sl(),
      updatePronunciationSettingsFromVoice: sl(),
      getPronunciationDemonstrationSentence: sl(),
      ttsService: core_di.sl(),
      settingsRepository: core_di.sl(),
    );
  });

  sl.registerLazySingleton<HandlePronunciationSettingsOuterUpdate>(() {
    return HandlePronunciationSettingsOuterUpdateImpl(
      normalizeSpeechRate: sl(),
    );
  });

  sl.registerLazySingleton<Initialize>(() {
    return InitializeImpl(
      normalizeSpeechRate: sl(),
      getTtsVoice: core_di.sl(),
    );
  });
}
